<?php
/*
 * [gen_recordindex]
 *
 */

namespace WebApper\Shortcode;

class GeneratorRecordIndex extends Generator {
	
    /**
     * Define shortcode properties
     *
     */
	protected $shortcode = 'generator_recordindex';

    /**
     * Handles the add post shortcode
     *
     * @param array $atts
     */
    public function shortcode( $atts ) {

		// Set data need for form
		$this->get_gen_form_data()

		?>
        <hr />
        <div class="alert alert-info fade in">
            <button type="button" class="close" data-dismiss="alert">&times;</button>
            <strong>How To!</strong> Use this tool to create a [recordindex] shortcode. Fill out the form, update the shortcode &amp; copy the shortcode to your desired page. Be sure to go through each tab! Remember the order which fields are displayed can be edited in the Field Builder.
        </div>
        
        <form name="generator_form" id="generator_form" action="" method="post" novalidate>
        
            <div class="tabbable">
            
                <ul class="nav nav-tabs">
                    <li class="active"><a href="#tab-indextable-settings" data-toggle="tab">Indextable Settings</a></li>
                    <li><a href="#tab-indextable-view" data-toggle="tab">Indextable View</a></li>
                    <li><a href="#tab-indextable-fields" data-toggle="tab">Indextable Fields</a></li>
                    <li><a href="#tab-indextable-messages" data-toggle="tab">Indextable Messages</a></li>
                    <li><a href="#tab-indextable-attributes" data-toggle="tab">Attribute reference</a></li>
                </ul>
                
                <div class="tab-content" style="min-height:305px;">
              
                    <div class="tab-pane row active" id="tab-indextable-settings">
                        <div class="span4">
                            <label for="id"><strong>Indextable ID:</strong></label>
                            <input type="text" name="id">
                            <span class="help-block">A unique ID to use for the shortcode. Must be alphanumeric: contain only lowercase letters, numbers and underscores(_).</span>
                        </div>
                        <div class="span4">
                            <label for="usercap"><strong>Minimum user capability:</strong></label>
                            <select name="usercap">
								<?php echo $this->wp_user_caps; ?>
                            </select>
                            <span class="help-block">The minimum user capability required to view the indextable.</span>
                        </div>
                        <div class="span4">
                            <label for="editor"><strong>Editor:</strong></label>
                            <select name="editor">
                                <option value="true">enable the editor buttons</option>
                                <option value="false">don't enable the editor buttons</option>
                            </select>
                            <span class="help-block">Whether to enable the editor buttons (Add, Edit, Delete) for the indextable.</span>
                        </div>
                    </div><!-- /.tab-pane -->
                    
                    <div class="tab-pane row" id="tab-indextable-view">
                        <div class="span4">
                            <label for="tableclasses"><strong>Table styles:</strong></label>
                            <select name="tableclasses" multiple>
                                <option value="table-bordered">bordered</option>
                                <option value="table-striped">striped rows</option>
                                <option value="table-hover">row hover</option>
                                <option value="table-condensed">condensed</option>
                            </select>
                            <span class="help-block">Optional styles to use to display the indextable.<br />Mix &amp; match!</span>
                        </div>
                   </div><!-- /.tab-pane -->
                    
                    <div class="tab-pane row" id="tab-indextable-fields">
                        <div class="span12">
                            <div class="alert alert-info fade in">
                                <button type="button" class="close" data-dismiss="alert">&times;</button>
                                <strong>How To!</strong> Use the Ctrl/Cmd button to select multiple options, or deselect an option on multiselect boxes.
                            </div>
                        </div>
                        <div class="span4">
                            <label for="posttype"><strong>Post Type:</strong></label>
                            <select name="posttype">
                                <option></option>
                                <?php echo $this->web_apper_cpts_options; ?>
                            </select>
                            <span class="help-block">The post type to use with the Indextable.</span>
                            <label for="fieldset"><strong>Fieldset:</strong></label>
                            <select name="fieldset" multiple="multiple">
                                <?php echo $this->web_apper_fieldsets_options; ?>
                            </select>
                            <span class="help-block">The set of fields to include in the form.</span>
                        </div>
                        <div class="span4">
                            <label for="include"><strong>Include fields:</strong></label>
                            <select name="include" multiple="multiple">
                                <?php echo $this->web_apper_fields_options; ?>
                            </select>
                            <span class="help-block">Individual fields to include in the form.</span>
                            <label for="exclude"><strong>Exclude fields:</strong></label>
                            <select name="exclude" multiple="multiple" disabled></select>
                            <span class="help-block">Individual fields to exclude from the form, e.g., exclude a field in one of the selected fieldsets.</span>
                        </div>
                        <div class="span4">
                            <label for="titlefield"><strong>Post title field:</strong></label>
                            <select name="titlefield" multiple="multiple"></select>
                            <span class="help-block">The field to use for the post title. Try using fields with unique values like name and/or address. This will be the post title seen if the post type is visible in the WP Administration area.</span>
                            <label for="linkedfield"><strong>Linked field:</strong></label>
                            <select name="linkedfield"></select>
                            <span class="help-block">The field to use as a link to the 'single-view' for a record. The single-view for a post type is setup using the [single-view] shortcode.</span>
                        </div>
                    </div><!-- /.tab-pane -->

                    <div class="tab-pane row" id="tab-indextable-messages">
                        <div class="span4">
                            <label for="successsave"><strong>Save successful message:</strong></label>
                            <input type="text" name="successsave" class="span4">
                            <span class="help-block">The message to display upon a successful indextable editor submission. Default 'Save successful!'</span>
                            <label for="failuresave"><strong>Save unsuccessful message:</strong></label>
                            <input type="text" name="failuresave" class="span4">
                            <span class="help-block">The message to display upon an unsuccessful indextable editor submission. Default 'Save unsuccessful.'</span>
                        </div>
                        <div class="span4">
                            <label for="successupdate"><strong>Update successful message:</strong></label>
                            <input type="text" name="successupdate" class="span4">
                            <span class="help-block">The message to display upon a successful indextable editor submission. Default 'Update successful!'</span>
                            <label for="failureupdate"><strong>Update unsuccessful message:</strong></label>
                            <input type="text" name="failureupdate" class="span4">
                            <span class="help-block">The message to display upon an unsuccessful indextable editor submission. Default 'Update unsuccessful.'</span>
                        </div>
                        <div class="span4">
                            <label for="successdelete"><strong>Delete successful message:</strong></label>
                            <input type="text" name="successdelete" class="span4">
                            <span class="help-block">The message to display upon a successful indextable editor submission. Default 'Deletion successful!'</span>
                            <label for="failuredelete"><strong>Delete unsuccessful message:</strong></label>
                            <input type="text" name="failuredelete" class="span4">
                            <span class="help-block">The message to display upon an unsuccessful indextable editor submission. Default 'Deletion unsuccessful.'</span>
                        </div>
                    </div><!-- /.tab-pane -->

                    <div class="tab-pane row" id="tab-indextable-attributes">
                        <div class="span12">
                            <h4>Indextable shortcode attribute reference</h4>
                            <dl>
                                <dt>id:</dt><dd> The unique ID to use for the indextable. Default: none. Required.</dd>
                                <dt>usercap:</dt><dd> The minimum user capability required to access the Indextable. OPTIONS: 'logged_out', 'read', 'edit_posts', 'edit_others_posts', 'edit_users', 'edit_pages', 'edit_plugins'. Default: 'edit_others_posts'.</dd>
                                <dt>posttype:</dt><dd> The cutom post type to display. Default: none. Required.</dd>
                                <dt>fieldset:</dt><dd> The set of fields to include in the indextable. Default: none. Required if 'include' is not specified. You may use one or both.</dd>
                                <dt>include:</dt><dd> field-id's of individual fields to include in the indextable. Default: none. Required if 'fieldset' is not specified. You may use one or both.</dd>
                                <dt>exclude:</dt><dd> field-id's of individual fields to exclude in the indextable. Default: none</dd>
                                <dt>titlefield:</dt><dd> The field to use for new rocord post titles. Default: none.</dd>
                                <dt>linkedfield:</dt><dd> The field to link a record to it's single view. Default: none.</dd>
                                <dt>editor:</dt><dd> Whether to enable add, edit & delete controls to the indextable. OPTIONS: true, false. Default: true.</dd>
                                <dt>tableclasses:</dt><dd> Adjusts how the indextable will display. Default: 'table-bordered,table-striped,table-hover,table-condensed'.</dd>
                                <dt>successsave:</dt><dd> The message to display upon successful editor save. Default: 'Save successful!'</dd>
                                <dt>failuresave:</dt><dd> The message to display upon unsuccessful editor save. Default: 'Save unsuccessful.'</dd>
                                <dt>successupdate:</dt><dd> The message to display upon successful editor update. Default: 'Update successful!'</dd>
                                <dt>failureupdate:</dt><dd> The message to display upon unsuccessful editor update. Default: 'Update unsuccessful.'</dd>
                                <dt>successdelete:</dt><dd> The message to display upon successful editor deletion. Default: 'Deletion successful!'</dd>
                                <dt>failuredelete:</dt><dd> The message to display upon unsuccessful editor deletion. Default: 'Deletion unsuccessful.'</dd>
                            </dl>
                        </div>
                    </div><!-- /.tab-pane -->

                </div><!-- End inner .tab-content -->
                
            </div><!-- End inner .tabbable -->
            
            <hr>
            
            <div class="row">
                <button type="submit" class="btn btn-large btn-primary span4 offset4">Update Shortcode</button>
            </div> 

        </form>
  
        <textarea id="shortcode" rows="3" onClick="this.select();" style="width:100%; text-align: center; -moz-box-sizing:border-box; -webkit-box-sizing:border-box; box-sizing:border-box;" class="well">[recordindex]</textarea>
		<?php

		$this->add_generator_js();

	}

}

$initialize = new GeneratorRecordIndex(); 

?>